<?php
// 获取订单列表
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

if(empty($_GET['oid'])){
    $sql = "SELECT * FROM tb_order_info
    LEFT JOIN tb_goods_info ON tb_order_info.g_id = tb_goods_info.g_id
    WHERE tb_order_info.o_status = 1
    ORDER BY tb_order_info.id DESC";
}else{
    $sql = "SELECT * FROM tb_order_info
    LEFT JOIN tb_goods_info ON tb_order_info.g_id = tb_goods_info.g_id
    WHERE tb_order_info.o_id LIKE '%".$_GET['oid']."%' 
    AND tb_order_info.o_status = 1
    ORDER BY tb_order_info.id DESC";
}

$result = mysqli_query($conn,$sql);

if($result){
    if(mysqli_num_rows($result)>0){
        while($row = mysqli_fetch_assoc($result)){
            echo"
            <tr>
                <th scope='row'>".$row['o_id']."</th>
                <td>".$row['o_name']."</td>
                <td>".$row['o_address']."</td>
                <td>".$row['o_phone']."</td>
                <td>".$row['o_begintime']."</td>
                <td>".$row['g_name']."</td>
                <td>".$row['o_num']."</td>
                <td>".$row['o_pay']." 元</td>
                <td>".$row['o_shippedtime']."</td>
            </tr>";
        }
    }else{
        echo"<tr><td colspan='9'>暂无订单数据</td></tr>";
    }
}else{
    echo"<tr><td colspan='9'>查询失败</td></tr>";
}